/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.telsoft.security.data;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ResourceBundle;
import org.apache.commons.dbutils.DbUtils;

/**
 *
 * @author nguyenthang
 */
public class SEC_DAOHelper {
    private String strConnectionString;
    private String strUser;
    private String strPass;
    public SEC_DAOHelper()
    {
        strConnectionString = ResourceBundle.getBundle("connection").getObject("SEC_ConnectionString").toString();
        strUser = ResourceBundle.getBundle("connection").getObject("SEC_User").toString();
        strPass = ResourceBundle.getBundle("connection").getObject("SEC_Pass").toString();
    }
    public Connection dbConnect()
    {
        try
        {
                DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
                Connection conn = DriverManager.getConnection(strConnectionString, strUser, strPass);
                return conn;
        }
        catch (Exception e)
        {
            return null;
        }
    }
    public void dbClose(Connection connection)
    {
        DbUtils.closeQuietly(connection);
    }
    public void dbClose(PreparedStatement stmt)
    {
        DbUtils.closeQuietly(stmt);
    }
    public void dbClose(ResultSet rs)
    {
        DbUtils.closeQuietly(rs);
    }
    public void dbClose(Connection connection, PreparedStatement stmt, ResultSet rs)
    {
        DbUtils.closeQuietly(connection,stmt,rs);
    }
}
